import { request } from '@/utils/request';

const API = {
  list: '/system/dict/data/list',
  detail: '/system/dict/data',
  info: '/system/dict/data',
  dictType: '/system/dict/data/type',
};

// 查询字典数据列表
export function getList(query?: Record<string, any>): Promise<any> {
  return request.get({
    url: API.list,
    params: query,
  });
}
// 查询字典数据详细
export function getInfo(dictCode: string | number): Promise<any> {
  return request.get({
    url: `${API.detail}/${dictCode}`,
  });
}
// 根据字典类型查询字典数据信息
export function getDicts(dictType: string): Promise<any> {
  return request.get({
    url: `${API.dictType}/${dictType}`,
  });
}
// 新增字典数据
export function add(data: Record<string, any>): Promise<any> {
  return request.post({
    url: API.detail,
    data,
  });
}
// 修改字典数据
export function edit(data: Record<string, any>): Promise<any> {
  return request.put({
    url: API.detail,
    data,
  });
}
// 删除字典数据
export function Delete(dictCode: string | number): Promise<any> {
  return request.delete({
    url: `${API.detail}/${dictCode}`,
  });
}
